package com.soft.javase.ch10.test.stream;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/**
 * @author wangzhisen
 * @Desc TODO
 * @date 2025/5/7
 * 5.获取Integer集合中最大值
 */
public class MaxNumber {
    public static void main(String[] args) {
        List<Integer> numbers = Arrays.asList(3, 7, 2, 9, 5, 1);

        Optional<Integer> max = numbers.stream()
                .max(Integer::compare);

        max.ifPresent(m -> System.out.println("最大值: " + m));
    }
}